<?php
/**
 * Created by PhpStorm.
 * User: td
 * Date: 15/1/7
 * Time: 上午12:21
 */

//手机验证码

function post($curlPost,$url){
    //$url = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_NOBODY, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
    $return_str = curl_exec($curl);
    curl_close($curl);
    return $return_str;
}


function xml_to_array($xml){
    $reg = "/<(\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
    if(preg_match_all($reg, $xml, $matches)){
        $count = count($matches[0]);
        for($i = 0; $i < $count; $i++){
            $subxml= $matches[2][$i];
            $key = $matches[1][$i];
            if(preg_match( $reg, $subxml )){
                $arr[$key] = xml_to_array( $subxml );
            }else{
                $arr[$key] = $subxml;
            }
        }
    }
    return $arr;
}

//判断登陆状态
function loginStatus(){
    if (isset($_SESSION['loginUser'])) {

    } else {
        $loginurl = U('Login/index');
        //dump($loginurl);
        echo "<script>alert('请登录系统！');window.location.href='{$loginurl}' </script>";

    }
}

//
function loginStatusAjax(){
    if (isset($_SESSION['loginUser'])) {

    } else {
        $loginurl = U('Login/index');
        //dump($loginurl);
        //$this->error("请登陆系统",$loginurl);
        exit;
    }
}

?>